﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.ServiceModel.Messaging
{
    public class MessageHeaderValueContextExtension : IExtension<OperationContext>
    {
        private readonly object _contextValue;
        private readonly string _key;

        public MessageHeaderValueContextExtension(string key, object value)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(key), "key could not be null or empty.");

            _key = key;
            _contextValue = value;
        }

        public object ContextValue
        {
            get
            {
                return _contextValue;
            }
        }

        public string Key
        {
            get
            {
                return _key;
            }
        }

        public void Attach(OperationContext owner)
        {
        }

        public void Detach(OperationContext owner)
        {
        }
    }
}
